package com.springmvc.crud.handler;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created by BF100233 on 2016/10/10.
 */

/**
 * 全局处理异常的类
 */
//@ControllerAdvice
public class HandlerException {

    @ExceptionHandler
    public ModelAndView handlerArithmeticException(Exception ex) {
        System.out.println("----->出异常了：" + ex);
        ModelAndView mv = new ModelAndView("error");
        mv.addObject("exception", ex);
        return mv;
    }

}
